import { PageTool } from "../../../../common/global/PageTool";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { ObjCreate } from "../../common/ObjCreate";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ItemCellRenderer } from "../../common/ItemCellRenderer";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class GuildAnimalRewardPanel
    
    export  class GuildAnimalRewardPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._pageTool = new PageTool([], 5);
            this.init();
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            this._itemsArray = arg1;
            this._pageTool.array = this._itemsArray;
            this._itemList.dataProvider = new DataProvider(this._pageTool.getByPageNo(1));
            return;
        }

        /* internal  */init(): void
        {
            this._leftBtn = ObjCreate.createGLoadedButton(ResFileConst.GuildAnimalLeft, 0, 0, 42, 48, this);
            this._rightBtn = ObjCreate.createGLoadedButton(ResFileConst.GuildAnimalRight, 260, 0, 42, 48, this);
            this._leftBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onTurnBtnClickHandler);
            this._rightBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onTurnBtnClickHandler);
            var loc1=0;
            while (loc1 < 5) 
            {
                ObjCreate.createBg(46 + loc1 * 43, 5, 38, 38, this, ImagesConst.PackItemBg);
                ++loc1;
            }
            this._itemList = ObjCreate.createTileList(48, 7, 43 * 5, 38, this);
            this._itemList.columnWidth = 43;
            this._itemList.rowHeight = 38;
            this._itemList.setStyle("cellRenderer", ItemCellRenderer);
            return;
        }

        /* internal  */onTurnBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as GLoadedButton).styleName;
            if (loc1 != ResFileConst.GuildAnimalLeft) 
            {
                if (this._page < this._pageTool.pagesCount) 
                {
                    loc3 = ((loc2 = this)._page + 1);
                    loc2._page = loc3;
                }
                else 
                {
                    this._page = this._pageTool.pagesCount;
                }
            }
            else if (this._page > 1) 
            {
                var loc2;
                var loc3=((loc2 = this)._page - 1);
                loc2._page = loc3;
            }
            else 
            {
                this._page = 1;
            }
            this._itemList.dataProvider = new DataProvider(this._pageTool.getByPageNo(this._page));
            return;
        }

        /* internal */ /* var */_itemList: GTileList;

        /* internal */ /* var */_leftBtn: GLoadedButton;

        /* internal */ /* var */_rightBtn: GLoadedButton;

        /* internal */ /* var */_itemsArray: Array<any>;

        /* internal */ /* var */_pageTool: PageTool;

        /* internal */ /* var */_page: int=1;
    }
